package com.xhs.main.service.yfb.impl;

import com.xhs.main.dao.yfb.YfbDesignMapper;
import com.xhs.main.entity.yfb.YfbDesign;
import com.xhs.main.entity.yfb.YfbDesignExample;
import com.xhs.main.service.yfb.YfbDesignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @create 2020-10-22 23:35
 */
@Service
public class YfbDesignServiceImpl implements YfbDesignService {
    @Autowired
    YfbDesignMapper yfbDesignMapper;

    @Override
    public void createDesign(YfbDesign yfbDesign) {
            yfbDesignMapper.insert(yfbDesign);
    }

    @Override
    public List<YfbDesign> queryAllDesigns() {
        return yfbDesignMapper.selectByExample(new YfbDesignExample());
    }

    @Override
    public List<YfbDesign> queryDesignByItemId(String itemId) {
        YfbDesignExample example = new YfbDesignExample();
        YfbDesignExample.Criteria criteria = example.createCriteria();
        //条件查项目表主键
        criteria.andYfbDesignItemIdEqualTo(itemId);
        return yfbDesignMapper.selectByExample(example);
    }

    @Override
    public List<YfbDesign> queryDesignByDevelop(String develop) {
        YfbDesignExample example = new YfbDesignExample();
        YfbDesignExample.Criteria criteria = example.createCriteria();
        //条件查开发分类：软硬
        criteria.andYfbDesignDevelopsortEqualTo(develop);
        return yfbDesignMapper.selectByExample(example);
    }

    @Override
    public List<YfbDesign> queryDesignByItemIdAndDevelop(String itemId, String develop) {
        YfbDesignExample example = new YfbDesignExample();
        YfbDesignExample.Criteria criteria = example.createCriteria();
        //条件查项目表主键
        criteria.andYfbDesignItemIdEqualTo(itemId);
        //条件查开发分类：软硬
        criteria.andYfbDesignDevelopsortEqualTo(develop);
        return yfbDesignMapper.selectByExample(example);
    }
}
